package com.HeJing.成员变量与局部变量的对比练习;

/**
 * ClassName: Person
 * Package: com.HeJing.面向对象概述.类的实例化与对象的内存解析
 * Description:
 *
 * @Author: HeJing
 * @Create: 2023-03-19 23:30
 * @Version: 1.0
 */
public class Person {
    // 成员变量/属性:
    String name;
    int age;
    char gender;

    // 方法:
    public void eat(){
        String food = "宫保鸡丁";   // food: 局部变量
        System.out.println(name + "在吃"  + food);
    }

    public void sleep(int hour){   // hour: 局部变量
        System.out.println(name + "必须保持每天" + hour + "小时的睡眠");
    }

    public void interest(String hobby){
        System.out.println(name + "的爱好是: " + hobby);
    }
}
















